﻿<%@ Page Title="" Language="C#" MasterPageFile="~/MasterPage/List2.Master" AutoEventWireup="true" CodeBehind="BatchInfo.aspx.cs" Inherits="Honestysoft.Financing.WebUI.Module.Audit.BatchInfo" %>
<%@ Register src="../../Workflow/Apply/WFButtons.ascx" tagname="WFButtons" tagprefix="uc1" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
    <script language="javascript" type="text/javascript">
        var opts = null;
        function InitRules() {
            opts = {
                 rules:
                 {
					<%= numBatchNo.UniqueID%>:{required: true,digits: true},
					<%= ddlBatchStatus.UniqueID%>:{required: true}					
                 },
                 messages:
                 {
					<%= numBatchNo.UniqueID%>:{required: "批次 请输入合适的值",digits: "批次 请输入有效的整数"},
					<%= ddlBatchStatus.UniqueID%>:{required: "状态 请选择合适的值"}					
                 },
                 onfocusout:false,
                 onclick:false,
                 onkeyup:false,
                 errorPlacement: function(error, element) {
                    $("#errorContainer").show();
                    error.html("<li>* "+error.html()+"</li>");
                    error.appendTo("#errorContainer");
                 },
                 wrapper:"li"
            }
        }
        function checkCanLock(){
            $.ajax({
                    type: "POST",
                    url: 'CheckBatch.ashx?ID=<%=Request["ID"]+"" %>&Type=1&randID=' + escape(new Date()),
                    success: function (msg) {
                        if(msg != "0"){
                            alert("当前存在"+msg+"个作业表未处于锁定或输出状态，不能锁定此批次！");
                            return false;
                        }
                        else{
                            return true;
                        }
                    },
                    error: function () { unlocking(); alert('服务器出错,无法获取数据！'); }
                });
            return false;
        }
        function checkCanOutPut(){
//            $.ajax({
//                    type: "POST",
//                    url: 'CheckBatch.ashx?ID=<%=Request["ID"]+"" %>&Type=2&randID=' + escape(new Date()),
//                    success: function (msg) {
//                        alert(msg);
//                        if(msg != "0"){
//                            alert("进行流程处理将结束并输出此批次，但当前存在"+msg+"个作业表未处于锁定或输出状态，不能执行流程处理！");
//                            return false;
//                        }
//                        else{
//                            return true;
//                        }
//                    },
//                    error: function () { unlocking(); alert('服务器出错,无法获取数据！'); }
//                });
//            return false;
            var val =document.getElementById("<%=hidIsCanOuput.ClientID %>").value;
            if(val !="0"){
                alert("进行流程处理将结束并输出此批次，但当前存在"+val+"个作业表未处于锁定或输出状态，不能执行流程处理！");
                return false;
            }
            return true;
        }
    </script>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
    <div class="infoContainer">
        <asp:Label runat="server" ID="lblInfo" Text=""></asp:Label><br />
        A.当前批次状态为：<asp:Label runat="server" ID="lblStatus" Text=""></asp:Label><br />
        B.操作指引：导入回执 → 派单 → 流程处理（锁定批次） → 流程处理（结束并输出批次）
        <%--（1）请先导入本批次的收文回执，系统将自动生成本批次的内部审核作业表；<br />
        （2）对系统自动生成本批次内部审核作业表进行派单，将作业表发送给相应初审人员；<br />
        （3）确认已导入本批次的所有收文回执，并全部正确派单后，执行“流程处理”来锁定本批次；<br />
        （4）批次锁定后，将不能再导入收文回执；如果要重新导入收文回执，必须是批次的锁定人员进行“流程收回”来进行解锁；<br />
        （5）本批次的全部内部审核作业表输出完成后，执行“流程处理”来结束并输出本批次，批次输出后将不能再进行任何操作；--%>
    </div>
    <div class="button_area">
        <asp:HiddenField runat="server" ID="hidIsCanOuput" />
        <uc1:WFButtons ID="WFButtons1" runat="server" />
        <asp:Button runat="server" ID="btnSave" Text="保存" CssClass="btn_normal" 
			onMouseOver="this.className='btn_active'" 
            onMouseOut="this.className='btn_normal'" onclick="btnSave_Click" />
    </div>
    <table cellpadding="0" width="100%" cellspacing="0" border="1" class="tEdit">
		<tr>
			<td style="width:100px;" class="title1">批次</td>
			<td><asp:TextBox ID="numBatchNo" runat="server" Enabled="false" cssClass="input2" onbeforepaste="numboxPaste();" onkeypress="isInt();" Width="96%"></asp:TextBox></td>
            <td style="width:100px;" class="title1">状态</td>
			<td><asp:DropDownList ID="ddlBatchStatus"  Enabled="false" runat="server" cssClass="input2"  Width="98%"></asp:DropDownList></td>
		</tr>
		<tr>
			<td class="title1">预计开始时间</td>
			<td><asp:TextBox ID="dtpPStartDate" runat="server" cssClass="input2" onfocus="setday(this);" Width="96%"></asp:TextBox></td>
			<td class="title1">预计结束时间</td>
			<td><asp:TextBox ID="dtpPEndDate" runat="server" cssClass="input2" onfocus="setday(this);" Width="96%"></asp:TextBox></td>
		</tr>
		<tr>
			<td class="title1">实际开始时间</td>
			<td><asp:TextBox ID="dtpStartDate" runat="server" cssClass="input2" onfocus="setday(this);" Width="96%"></asp:TextBox></td>
			<td class="title1">实际结束时间</td>
			<td><asp:TextBox ID="dtpEndDate" runat="server" cssClass="input2" onfocus="setday(this);" Width="96%"></asp:TextBox></td>
		</tr>
        <tr>
            <td class="title1">创建人</td>
			<td><asp:TextBox ID="txtCreator" runat="server"  Enabled="false" cssClass="input2" MaxLength="36" Width="96%"></asp:TextBox>
            <asp:HiddenField runat="server" ID="hidCreator" />
            </td>
            <td class="title1">创建时间</td>
			<td><asp:TextBox ID="dtpCreateTime" runat="server" Enabled="false" cssClass="input2" onfocus="setday(this);" Width="96%"></asp:TextBox></td>
        </tr>
         <tr>
            <td class="title1">收文回执及<br />作业表</td>
            <td colspan="3">
                <div class="button_area">
        <asp:Button runat="server" ID="btnImportRec" CssClass="btn_big_normal" 
			onMouseOver="this.className='btn_big_active'" 
            onMouseOut="this.className='btn_big_normal'" Text="导入收文回执" OnClientClick="return mImportRec();" onclick="btnImportRec_Click" 
                        />
        <asp:Button runat="server" ID="btnDelete" CssClass="btn_normal" 
			onMouseOver="this.className='btn_active'" 
            onMouseOut="this.className='btn_normal'" Text="删 除" 
            OnClientClick="javascript:return getNoSelectionAlert('chkID','请选择要删除的记录后再执行此操作！');" 
                        onclick="btnDelete_Click" />
        <asp:Button runat="server" ID="btnSend" CssClass="btn_normal" 
			onMouseOver="this.className='btn_active'" 
            onMouseOut="this.className='btn_normal'" Text="派 单" 
            OnClientClick="javascript:return mDoSend();" 
                       />
                       <asp:Button runat="server" ID="btnRecall" CssClass="btn_normal" style="display:none"
			onMouseOver="this.className='btn_active'" 
            onMouseOut="this.className='btn_normal'" Text="收 回" 
            OnClientClick="javascript:return mDoRecall();" 
                       />
    </div>
                <table cellpadding="0" width="100%" cellspacing="0" border="1" class="t1" id="tGrid">                   
                    <thead>  
                        <th align="center" width="30px">
                            <input type="checkbox" name="chkAll" value="checkbox" onclick='javascript:checkAll(this,"chkID")' />
                        </th>
                        <th>合同名称</th>
                        <th width="60px">回执编号</th>
                        <th width="120px">作业表编号</th>
                        <th width="80px">申请资金</th>
                        <th width="40px">当前状态</th>
                        <th width="60px">操作</th>
                    </thead>
                    <asp:Repeater runat="server" ID="rptBatchContract">
                        <ItemTemplate>
                            <tr title='<%# GetToolTips(Container.DataItem) %>'>
                                <td>
                                    <%# GetCheckBox(DataBinder.Eval(Container.DataItem, "ID") + "",DataBinder.Eval(Container.DataItem,"TableID") +"", Convert.ToBoolean(DataBinder.Eval(Container.DataItem, "IsReceive")))%>
                                  </td>
                                <td align="left" ><%# DataBinder.Eval(Container.DataItem,"ContractName") %>
                                <td><%# DataBinder.Eval(Container.DataItem, "RecCode")%></td>
                                <td><%# DataBinder.Eval(Container.DataItem, "TableCode")%></td>
                                <td align="right"><%# string.Format("{0:0.00}", DataBinder.Eval(Container.DataItem,"Amount")) %></td>
                                <td><%# GetStatus(Container.DataItem)%></td>
                                <td><%#GetLinkControl(DataBinder.Eval(Container.DataItem, "ID") + "", Convert.ToBoolean(DataBinder.Eval(Container.DataItem, "IsSend")), Convert.ToBoolean(DataBinder.Eval(Container.DataItem, "IsReceive")), Convert.ToBoolean(DataBinder.Eval(Container.DataItem, "IsBack")))%></td>
                            </tr>
                        </ItemTemplate>
                    </asp:Repeater>
                    <tr style="display:none"><td colspan="7"></td></tr>
                </table>
            </td>
        </tr>
		<tr>
			<td class="title1">批次说明</td>
			<td colspan="3"><asp:TextBox ID="txtRemark" runat="server" TextMode="MultiLine" Rows="10" cssClass="input2" MaxLength="500" Width="98%"></asp:TextBox></td>			
		</tr>
        </table>
        <asp:HiddenField runat="server" ID="hidIsHasRec" />
        <asp:HiddenField runat="server" ID="hisIsHasNoSend" />
        <script language="javascript" type="text/javascript">
            function checkHasRec() {
                var hasRec = document.getElementById("<%=hidIsHasRec.ClientID %>").value;
                if (hasRec == "0") {
                    return confirm("本批次没有导入对应的收文回执，没有生成内部审核作业表，你确定仍然要执行流程处理吗？");
                }
                var hasNoSend = document.getElementById("<%=hisIsHasNoSend.ClientID %>").value;
                if (hasNoSend != "0") {
                    alert("存在" + hasNoSend + "条记录未进行派单，不能进行流程操作！");
                    return false;
                }
                return true;
            }
            function mImportRec() {
                var retValue = window.showModalDialog('SelectDocRec.aspx?ID=<%=Request["ID"]+"" %>&FunctionID=<%=Request["FunctionID"]+"" %>&randId=' + escape(new Date()), window, 'scroll:0;status:0;help:1;resizable:0;dialogWidth:900px;dialogHeight:600px');
                if (typeof (retValue) != "undefined" && retValue) {                    
                    return true;
                }
                return false;
            }
            function getSelected() {
                var dataIdString = "";
                var elm = document.getElementsByName("chkID");
                if (elm != null) {
                    for (i = 0; i < elm.length; i++) {
                        if (elm[i].checked) {
                            if (dataIdString != "") {
                                dataIdString += ",";
                            }
                            dataIdString += elm[i].value.split('|')[1];
                        }
                    }
                }
                return dataIdString;
            }
            function mDoSend() {
                var dataIdString = getSelected();
                if (dataIdString == "") {
                    alert('请选择要派单的记录后再执行此操作！');
                    return false;
                }
                return mDoWorkflowStart('<%=Honestysoft.Baseframework.WebUI.Globals.Home %>', '<%=((int)Honestysoft.Financing.Model.EnumItem.WFBill.AuditTable).ToString() %>', dataIdString, '<%=Honestysoft.Baseframework.WebUI.UserLoginer.LoginUser.ID %>', "", "")
            }
            function mDoRecall() {
                var dataIdString = getSelected();
                if (dataIdString == "") {
                    alert('请选择要收回的记录后再执行此操作！');
                    return false;
                }
                return mDoWorkflowRecall('<%=Honestysoft.Baseframework.WebUI.Globals.Home %>', '<%=((int)Honestysoft.Financing.Model.EnumItem.WFBill.AuditTable).ToString() %>', dataIdString, '<%=Honestysoft.Baseframework.WebUI.UserLoginer.LoginUser.ID %>');
            }
        </script>
</asp:Content>
